package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	type Blacklist struct {
		models.BaseModel

		UserId  uint64 `gorm:"column:user_id;comment:发起人id;" db:"user_id" json:"user_id" form:"user_id"`     //用户ID
		BlackId uint64 `gorm:"column:black_id;comment:拉黑人id;" db:"black_id" json:"black_id" form:"black_id"` //拉黑人ID
		Type    uint8  `gorm:"column:type;comment:1乘客拉黑司机,2司机拉黑乘客;" db:"type" json:"type" form:"type"`       //黑名单类型：1乘客拉黑司机，2：司机拉黑乘客
		Reason  string `gorm:"type:varchar(255);comment:拉黑原因;" db:"reason" json:"reason" form:"reason"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&Blacklist{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&Blacklist{})
	}

	migrate.Add("2023_07_18_143631_add_blacklists_table", up, down)
}
